import { IColumnProps } from "devextreme-react/data-grid"
/**
 * 保证系统表
 */

export const guaranteeCoefficientDataSource = [
    {
        key: 1,
        rowName: 'highest',
        rowText: '最高',
        highest: 3,
        high: 2.7,
        middle: 2.3,
        low: 2
    },
    {
        key: 2,
        rowName: 'high',
        rowText: '高',
        highest: 2.7,
        high: 2.4,
        middle: 2,
        low: 1.6
    },
    {
        key: 3,
        rowName: 'middle',
        rowText: '中',
        highest: 2.3,
        high: 2.1,
        middle: 1.6,
        low: 1.2
    },
    {
        key: 4,
        rowName: 'low',
        rowText: '低',
        highest: 2,
        high: 1.6,
        middle: 1.2,
        low: 1
    },
]
function getHeaderTemplate(mainTitle: string, subTitle: string) {
    return `<div style="font-weight: normal ">${mainTitle}<div style="font-size: 14 ">${subTitle}</div></div>`
}
export function getRiskCoefficientColumns(): IColumnProps[] {
    return [
        {
            headerCellTemplate: getHeaderTemplate('评估的重大错报风险', ''),
            dataField: "rowText",
            alignment: 'center',
            caption: '评估的重大错报风险',
            allowFiltering: false,
            allowSorting: false,
            width: 150,
        },
        {
            headerCellTemplate: getHeaderTemplate('其他实质性程序未能发现重大错报的风险', ''),

            columns: [
                {
                    headerCellTemplate: getHeaderTemplate('最高', '(其他程序的保证程度:没有)'),
                    caption: '最高',
                    dataField: "highest",
                    alignment: 'center',
                    allowFiltering: false,
                    allowSorting: false,
                    width: 200
                },
                {
                    headerCellTemplate: getHeaderTemplate('高', '(其他程序的保证程度:有限的)'),
                    caption: '高',
                    dataField: "high",
                    alignment: 'center',
                    allowFiltering: false,
                    allowSorting: false,
                    width: 200
                },
                {
                    headerCellTemplate: getHeaderTemplate('中', '(其他程序的保证程度:中度的)'),
                    caption: '中',
                    dataField: "middle",
                    alignment: 'center',
                    allowFiltering: false,
                    allowSorting: false,
                    width: 200

                },
                {
                    headerCellTemplate: getHeaderTemplate('低', '(其他程序的保证程度:重要的)'),
                    caption: '低',
                    dataField: "low",
                    alignment: 'center',
                    allowFiltering: false,
                    allowSorting: false,
                    width: 200

                }
            ]
        }
    ]
}

/**
 * 获取保证系统
 * @param majorMisstatementRisk 
 * @param otherSubstantiveRisk 
 */
export function getGuaranteeCoefficient(majorMisstatementRisk: string, otherSubstantiveRisk: string): number {
    const guaranteeCoefficient: any = guaranteeCoefficientDataSource.find(item => item.rowName === majorMisstatementRisk);
    if (guaranteeCoefficient) {
        return Number(guaranteeCoefficient[otherSubstantiveRisk])
    }
    return 0;
}